package org.raymond.iworks.repository.utils;

import org.raymond.iworks.commons.utils.RandomValueUtil;
import org.raymond.iworks.repository.entity.TSysUser;

import java.util.Date;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
public class RandomUser {
    private String[] sexs = {"secret", "male", "female"};

    private RandomUser(){}
    public TSysUser build(String password){
        TSysUser tSysUser = TSysUser.builder()
                .username(randomUsername())
                .password(password)
                .mobile(randomMobile())
                .countryCode("+86")
                .sex(randomSex())
                .email(randomEmail())
                .birthday(randomBirthday())
                .source("system")
                .build();
        return tSysUser;
    }

    private String randomUsername(){
        return "匿名用户-"+ RandomValueUtil.getStr(10, 11);
    }

    private String randomEmail(){
        return RandomValueUtil.getEmail(5, 12);
    }

    private String randomMobile(){
        return RandomValueUtil.getTel();
    }

    private String randomSex(){
        return sexs[RandomValueUtil.getInt(0,3)];
    }

    private Date randomBirthday(){
        return RandomValueUtil.getDate("1970-01-01 00:00:00", "2004-01-01 00:00:00");
    }

    private static class InstanceHolder {
        private static final RandomUser INSTANCE = new RandomUser();
    }

    public static TSysUser create(String password){
        return RandomUser.InstanceHolder.INSTANCE.build(password);
    }
}
